<?php
//
// +------------------------------------------------------------------------+
// | PHP Version 5                                                          |
// +------------------------------------------------------------------------+
// | Copyright (c) All rights reserved.                                     |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License,        |
// | that is available at http://www.php.net/license/3_0.txt.               |
// | If you did not receive a copy of the PHP license and are unable to     |
// | obtain it through the world-wide-web, please send a note to            |
// | license@php.net so we can mail you a copy immediately.                 |
// +------------------------------------------------------------------------+
// | Author:                                                                |
// +------------------------------------------------------------------------+
//
// $Id$
//


/**
 * @author       sxin
 */
class MysqlPdoDriver extends PdoDriver {
    
    /**
     * 初始化连接
     * @param    array $config    
     * @return   void
     */
    public function __construct($config) {
        list($host, $port) = explode(':', $config['host']); 
        $this->pdo = new PDO('mysql:dbname='.$config['database'].';host='.$host.';port='.$port,
                             $config['login'], $config['password']);
        $this->config = $config;
        $this->prefix = $config['prefix'];
        if (!empty($config['encoding'])) {
            $this->setCharset($config['encoding']);
        }
    }
    
    /**
     * 设置MySQL编码
     *
     * @param string $encoding
     */
    public function setCharset($encoding) {
        $this->pdo->exec("SET NAMES '$encoding'");
    }
    
    public function quoteIdentifierSymbol($str) {
        return '`'.$str.'`';
    }
}

